<?php

namespace App\Models\Concerns;

use App\Models\Comment;

/**
 * Created by PhpStorm.
 * User: superxing-cto
 * Date: 17/2/6
 * Time: 10:59
 */
trait CommentTraits
{
    public function comments()
    {
        return $this->hasMany(Comment::class, 'type_id', 'id')->where('type', $this->model_name())->where('parent_id', 0)->where('created_at', '<=', date('Y-m-d H:i:s'))->orderBy('created_at', 'desc');
    }
    public function all_comments()
    {
        return $this->hasMany(Comment::class, 'type_id', 'id')->where('type', $this->model_name())->where('created_at', '<=', date('Y-m-d H:i:s'))->orderBy('created_at', 'desc');
    }
   
}